import React, { useEffect, useState } from 'react'
import api from '../../../api'
import OrderListView from '../OrderListView'
import './style.less'

const OrderList = (props) => {

  const [orderListData,setOrderListData] = useState([])

  useEffect(() => {
    api.commentOrder({
      username: props.user.nick
    }).then(res => {
      console.log(res)
      if(res.data.status === 200) {
        setOrderListData(res.data.result)
      } 
    }).catch(err => {
      console.log(err)
    })
  },[])

  return (
    <div>
      {
        orderListData.length > 0 ? <OrderListView user={props.user} data={orderListData} /> : <div className='load'>等待数据加载</div>
      }
    </div>
  )
}

export default OrderList